<?php

namespace app\api\controller;

use app\result\CodeResult;
use think\App;

class Code extends BaseIndex
{
    protected $unauthorized = ['code@reg', 'code@login', 'code@find_pwd', 'code@captcha'];

    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->objResult = new CodeResult();
    }

    //邮箱验证码
    public function send_code($email)
    {
        data_exit_json($this->objResult->send_code($email, 0));
    }

    public function bind_mobile()
    {
        data_exit_json($this->objResult->bind_mobile($this->param));
    }

    //发送验证码
    public function reg($phone)
    {
        data_exit_json($this->objResult->send_code($phone, 1));
    }

    //登录验证码
    public function login()
    {
        data_exit_json($this->objResult->send_code_login($this->param));
    }

    //找回密码验证码
    public function find_pwd()
    {
        data_exit_json($this->objResult->forget_code($this->param));
    }

    //图形验证码
    public function captcha()
    {
        data_exit_json((new CodeResult())->captcha_create());
    }
}
